<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1 , minimum-scale=1.0,maximum-scale =1.0,user-scalable=no">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>实名认证</title>
<link rel="stylesheet" type="text/css" href="../css/mui.picker.css">
<link rel="stylesheet" type="text/css" href="../css/mui.css">
<link rel="stylesheet" href="../css/global.css">
<link rel="stylesheet" href="../css/loading.css">
<style type="text/css">
body {
	padding: 0px;
	margin: 0px;
}

.a {
	text-align: center;
	margin-bottom: -10px;
	padding-left: -10;
	height: 0.5px;
	width: 6px;
	border-radius: 50%;
	background: -webkit-radial-gradient(rgba(0, 0, 0, 0.68) 5%, #32a04a 25%,
		rgba(0, 0, 0, 0.46) 50%);
	transform: scale(42, 1);
	display: inline-block;
}

.detail-top {
	border-bottom: solid 1px #ccc;
	height: 30px;
	padding-top: 6%;
}

.detail-real {
	float: left;
	margin-left: 5%;
}

.updown {
	padding-top: 5%;
}

.updown img {
	width: 300px;
	height: 40px;
}

.anzhuan {
	position: relative;
	margin-top: -9%;
	color: #FFF;
}

.id_card {
	position: absolute;
	display: inline-block;
	overflow: hidden;
	background: url();
	width: 30%;
	height: 100px;
	top: 5%;
	background-repeat: no-repeat;
	/* 	margin-top: 15%; */
	margin-left: 10%
}

.id_card img {
	display: inline-block;
	width: 100%;
	height: 100%
}

.face {
	margin-top: 80%;
	margin-left: 15%;
	color: #bababa
}

.id_card1 {
	position: absolute;
	display: inline-block;
	overflow: hidden;
	background: url();
	width: 30%;
	top: 5%;
	height: 100px;
	background-repeat: no-repeat;
	margin-left: 220px;
	/* margin-top:15% */
}

.id_card1 img {
	display: inline-block;
	width: 100%;
	height: 100%
}

.back {
	margin-top: 80%;
	margin-left: 15%;
	color: #bababa
}

.id_card input {
	position: absolute;
	right: 0px;
	top: 0px;
	opacity: 0;
	-ms-filter: 'alpha(opacity=0)';
	font-size: 20px;
}

.id_card1 input {
	position: absolute;
	right: 0px;
	top: 0px;
	opacity: 0;
	-ms-filter: 'alpha(opacity=0)';
	font-size: 20px;
}

#shenfen {
	margin-top: -20%;
	color: #bababa;
	margin-left: 10%;
	width: 40%;
}

#shenfen1 {
	margin-top: -5%;
	margin-left: 60%;
	color: #bababa;
	width: 40%;
}

#info {
	margin-top: 7%;
}

#body {
	background-color: #fff;
}

.mui-input-row {
	background-color: #FCFCFC
}

.loading {
	display: none;
	width: 160px;
	height: 56px;
	position: absolute;
	top: 50%;
	left: 32%;
	line-height: 56px;
	color: #fff;
	padding-left: 60px;
	font-size: 15px;
	background: #000 url(../img/loader.gif) no-repeat 10px 50%;
	opacity: 0.7;
	z-index: 9999;
	-moz-border-radius: 20px;
	-webkit-border-radius: 20px;
	border-radius: 20px;
	filter: progid:DXImageTransform.Microsoft.Alpha(opacity=70);
}
</style>
<script lang="javascript" src="../js/jquery-1.8.3.js"></script>
<script type="text/javascript" src="../js/layer/layer.js"></script>
<link rel="stylesheet" href="../js/layer/skin/layer.css" id="layuicss-skinlayercss">
<script src="../js/mui.min.js"></script>
<script src="../js/mui.picker.min.js"></script>
<script src="../js/data.city.js"></script>
<script type="text/javascript" src="../js/loading.js"></script>
<script type="text/javascript">
	var openID;
	$(function(){
		openID = GetQueryString("openID");
		localStorage.setItem("ll_openID", openID);
	})


	var aCity={ 11:"北京",12:"天津",13:"河北",14:"山西",15:"内蒙古",  
        21:"辽宁",22:"吉林",23:"黑龙江",31:"上海",32:"江苏",  
        33:"浙江",34:"安徽",35:"福建",36:"江西",37:"山东",41:"河南",  
        42:"湖北",43:"湖南",44:"广东",45:"广西",46:"海南",50:"重庆",  
        51:"四川",52:"贵州",53:"云南",54:"西藏",61:"陕西",62:"甘肃",  
        63:"青海",64:"宁夏",65:"新疆",71:"台湾",81:"香港",82:"澳门",91:"国外"  
    }; 
	function isCardID(sId){
		 var iSum=0 ;
		 var info="" ;
		 if(!/^\d{17}(\d|x)$/i.test(sId)){
			 return "你输入的身份证长度或格式错误";
		 } 
		 sId=sId.replace(/x$/i,"a");
		 if(aCity[parseInt(sId.substr(0,2))]==null){
			 return "你的身份证地区非法";
		 }
		 sBirthday=sId.substr(6,4)+"-"+Number(sId.substr(10,2))+"-"+Number(sId.substr(12,2));
		 var d=new Date(sBirthday.replace(/-/g,"/")) ;
		 if(sBirthday!=(d.getFullYear()+"-"+ (d.getMonth()+1) + "-" + d.getDate())){
			 return "身份证上的出生日期非法";
		 }
		 for(var i = 17;i>=0;i --) iSum += (Math.pow(2,i) % 11) * parseInt(sId.charAt(17 - i),11) ;
		 if(iSum%11!=1){
			 return "你输入的身份证号非法";
		 }
		 //aCity[parseInt(sId.substr(0,2))]+","+sBirthday+","+(sId.substr(16,1)%2?"男":"女");//此次还可以判断出输入的身份证号的人性别
		 return true;
	}
	//提交身份信息
	function nextone() {
		var openID = localStorage.getItem("ll_openID");
		var id_name = $("#id_name").val();
		var id_no = $("#id_no").val();
		var card_no = $("#card_no").val();
		var bank_phone = $("#bank_phone").val();
		
		var reg = /^1[3|4|5|7|8][0-9]{9}$/; //验证规则  
		if (id_name == "" || id_no == "" || bank_phone == "" || card_no == "") {
			layer.msg("所有信息必须填写完整！");
			return;
		};
		if(!reg.test(bank_phone.trim())){
		   layer.msg("手机号验证失败，请核对后再提交！");
		   return;
		};
		
		var isCard = isCardID(id_no);
		if(isCardID(id_no) != true){
			layer.msg(isCard);
			return;
		};
		
		var bankCheck = luhmCheck(card_no);
		if(bankCheck == false){
			layer.msg("银行卡验证失败,请核对后再提交！");
			return;
		}
		$.ajax({
			url : "../llPay/verified",
			type : "post",
			data : {
				"openID" : openID,
				"id_name" : id_name,
				"id_no" : id_no,
				"card_no" : card_no,
				"bank_phone" : bank_phone
			},
			success : function(res){
				if(res.result == "success"){
					localStorage.setItem("ll_id_name", id_name);
					localStorage.setItem("ll_bank_phone", bank_phone);
					localStorage.setItem("ll_id_no", id_no);
					localStorage.setItem("ll_card_no", card_no);
					alert("认证成功");
					window.location.href = "my.html";
				}else if(res.message.indexOf("已经被绑定") != -1){
					localStorage.setItem("ll_id_name", id_name);
					localStorage.setItem("ll_bank_phone", bank_phone);
					localStorage.setItem("ll_id_no", id_no);
					localStorage.setItem("ll_card_no", card_no);
					window.location.href = "my.html";
				}else{
					alert("认证失败：" + res.message);
				}
			},
			error : function(){
				alert("请求失败，请稍后再试！");
			}
		})
	};
	
	/* 获取url后的字符串 */
    function GetQueryString(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) {
            return (r[2]);
        }
        return null;
    }
	
  	//bankno为银行卡号 banknoInfo为显示提示信息的DIV或其他控件  
	function luhmCheck(bankno){  
	    var lastNum=bankno.substr(bankno.length-1,1);//取出最后一位（与luhm进行比较）  
	   
	    var first15Num=bankno.substr(0,bankno.length-1);//前15或18位  
	    var newArr=new Array();  
	    for(var i=first15Num.length-1;i>-1;i--){    //前15或18位倒序存进数组  
	        newArr.push(first15Num.substr(i,1));  
	    }  
	    var arrJiShu=new Array();  //奇数位*2的积 <9  
	    var arrJiShu2=new Array(); //奇数位*2的积 >9  
	       
	    var arrOuShu=new Array();  //偶数位数组  
	    for(var j=0;j<newArr.length;j++){  
	        if((j+1)%2==1){//奇数位  
	            if(parseInt(newArr[j])*2<9)  
	            arrJiShu.push(parseInt(newArr[j])*2);  
	            else  
	            arrJiShu2.push(parseInt(newArr[j])*2);  
	        }  
	        else //偶数位  
	        arrOuShu.push(newArr[j]);  
	    }  
	       
	    var jishu_child1=new Array();//奇数位*2 >9 的分割之后的数组个位数  
	    var jishu_child2=new Array();//奇数位*2 >9 的分割之后的数组十位数  
	    for(var h=0;h<arrJiShu2.length;h++){  
	        jishu_child1.push(parseInt(arrJiShu2[h])%10);  
	        jishu_child2.push(parseInt(arrJiShu2[h])/10);  
	    }          
	       
	    var sumJiShu=0; //奇数位*2 < 9 的数组之和  
	    var sumOuShu=0; //偶数位数组之和  
	    var sumJiShuChild1=0; //奇数位*2 >9 的分割之后的数组个位数之和  
	    var sumJiShuChild2=0; //奇数位*2 >9 的分割之后的数组十位数之和  
	    var sumTotal=0;  
	    for(var m=0;m<arrJiShu.length;m++){  
	        sumJiShu=sumJiShu+parseInt(arrJiShu[m]);  
	    }  
	       
	    for(var n=0;n<arrOuShu.length;n++){  
	        sumOuShu=sumOuShu+parseInt(arrOuShu[n]);  
	    }  
	       
	    for(var p=0;p<jishu_child1.length;p++){  
	        sumJiShuChild1=sumJiShuChild1+parseInt(jishu_child1[p]);  
	        sumJiShuChild2=sumJiShuChild2+parseInt(jishu_child2[p]);  
	    }        
	    //计算总和  
	    sumTotal=parseInt(sumJiShu)+parseInt(sumOuShu)+parseInt(sumJiShuChild1)+parseInt(sumJiShuChild2);  
	       
	    //计算Luhm值  
	    var k= parseInt(sumTotal)%10==0?10:parseInt(sumTotal)%10;          
	    var luhm= 10-k;  
	       
	    if(lastNum==luhm && lastNum.length != 0){  
	       //$("#banknoInfo").html("Luhm验证通过");  
	       return true;  
	    }  
	    else{  
	       //$("#banknoInfo").html("银行卡号必须符合Luhm校验");  
	       return false;  
	    }          
	}  
</script>
</head>
<body id="body">
	<div id="info">
		<div class="mui-input-group">
			<div class="mui-input-row" id="tian">
				<label>姓&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;名:</label> 
				<input type="text" class="mui-input-clear" id="id_name" placeholder="请输入身份证姓名" data-input-clear="1">
				<span class="mui-icon mui-icon-clear mui-hidden"></span>
			</div>

			<div class="mui-input-row">
				<label>身份证号:</label> 
				<input type="text" class="mui-input-clear" id="id_no" placeholder="请输入身份证号" data-input-clear="2">
				<span class="mui-icon mui-icon-clear mui-hidden"></span>
			</div>
			<!-- <div class="mui-input-row">
				<label>有效日期:</label> 
				<input type="text" class="mui-input-clear" id="limt" placeholder="" readonly data-input-clear="3">
				<span class="mui-icon mui-icon-clear mui-hidden"></span>
			</div> -->
			<div class="mui-input-row">
				<label>结算卡号:</label> 
				<input type="text" class="mui-input-clear" id="card_no" placeholder="请输入结算银行卡号" data-input-clear="4">
				<span class="mui-icon mui-icon-clear mui-hidden"></span>
			</div>
			<div class="mui-input-row">
				<label>预留手机:</label> 
				<input type="text" class="mui-input-clear" id="bank_phone" placeholder="请输入结算银行卡预留手机号" data-input-clear="5">
				<span class="mui-icon mui-icon-clear mui-hidden"></span>
			</div>
			<!-- <div class="mui-input-row">
				<label>所属地区:</label> 
				<input class="mui-input-clear" type="text" placeholder="请选择所属地区" readonly id="cityname" data-input-clear="6">
				<span class="mui-icon mui-icon-clear mui-hidden"></span> 
				<input style="display: none" type="text" id="provinceID"> 
				<input style="display: none" type="text" id="cityID"> 
				<input style="display: none" type="text" id="areaID">
			</div> -->
		</div>
	</div>
	<div class="out-side" style="text-align: center; padding-top: 10px;">
		<div class="updown">
			<img src="../img/btn_signin@2x.png">
		</div>
		<div class="anzhuan" onclick="nextone()">确认提交</div>
	</div>
</body>
</html>